home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9322 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  907 b 

  1. Path: nntp.onyx.net!newsmaster
  2. From: Nik.Palmer@onyx.octacon.co.uk (Nik Palmer)
  3. Newsgroups: comp.lang.c
  4. Subject: problem passing a string
  5. Date: Sat, 09 Mar 1996 12:36:03 GMT
  6. Organization: ONYX.net
  7. Message-ID: <4hrtsp$4mf@mulgave.octacon.co.uk>
  8. NNTP-Posting-Host: r03-17.onyx.net
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11. Hi,  Im using a textoutput routine in the fastgraph package of the
  12. form below
  13.     void fg_print(char *string,int n);
  14. The string that I want to pass is initialised as below
  15.  
  16. char string[6]
  17. double variable= 1.2345
  18. sprintf(string1,"%5f",variable)
  19.  
  20. fg_print(string1,5)
  21.  
  22. problem is it's outputting garbage, I know that string1 is only a
  23. pointer to the memory that holds the string, and that if I want to
  24. access the string I need string1[num].  So I think it's just
  25. outputting 5 bytes of memory from the memory location string1.
  26.  
  27. How do I  pass this routine the string??
  28. Thanks for your help.
  29. Nik
  30.  
  31.